<?php
class Silk_Mapi_DataController extends Silk_Mapi_Controller_Action{
    public function storeDataAction()
    {
        $ids = $this->getRequest()->getParams();
        $resource = Mage::getSingleton('core/resource');
        $db = $resource->getConnection('core_read');
        $idss = implode(',', $ids);
        if(!$idss) $idss = 0;
        $sql = "select count(entity_id) from sales_flat_order where status='complete' and customer_id in ({$idss})";
        $query = $db->query($sql);
        $count = $query->fetchColumn();
        $count = $count?$count:0;

        $sql = "select sum(grand_total) from sales_flat_order where status='complete' and customer_id in ({$idss})";
        $query = $db->query($sql);
        $total = $query->fetchColumn();
        $total = $total?$total:0.0000;

        $data = array('total'=>$total, 'count'=>$count);
        return $this->render($data);
    }
}